#ifndef _QY_RW_LOCK_H
#define _QY_RW_LOCK_H

#include <pthread.h>
#include "Noncopyable.h"

namespace qy
{

class RWLock : public Noncopyable
{
public:
	static RWLock *create();
	static void destroy(RWLock *lock);

	void rdlock();
	bool tryrdlock();
	void wrlock();
	bool trywrlock();
	void unlock();

private:
	RWLock(pthread_rwlock_t m_lock);
	~RWLock();

private:
	pthread_rwlock_t m_lock;
	
};

}

#endif
